from django.core.validators import RegexValidator

from test01.models import UserInfo
from utils.bookstrap import *


class UserInfoModelForm(BookStrapModelForm):
    mobile_phone = forms.CharField(label='手机号',
                                   validators=[RegexValidator(r'^(1[3|4|5|6|7|8|9])\d{9}$', '手机号格式错误'), ])
    password = forms.CharField(label='密码', widget=forms.PasswordInput())
    confirm_password = forms.CharField(label='重复密码', widget=forms.PasswordInput())
    code = forms.CharField(
        label='验证码',
        widget=forms.TextInput())

    class Meta:
        model = UserInfo
        fields = ['user_name', 'mail', 'password', 'confirm_password', 'mobile_phone', 'code']
